package sketch.instrumenter;

import java.util.Map;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TracerFileReaderTest extends TestCase {

	public static Test suite() {
		return new TestSuite(TracerFileReaderTest.class);
	}
	
	public void testReaderTraceFile() {
		String filePath = "./testfiles/sketch/instrumenter/traceFile.txt";
		TracerFileReader reader = new TracerFileReader(filePath);
		Map<String, Map<Integer, String>> parsingResults = reader.parse();
		assertEquals(1, parsingResults.size());
		
		assertTrue(parsingResults.containsKey("rewriteSize"));
		
		Map<Integer, String> content = parsingResults.get("rewriteSize");
		assertEquals(6, content.size());
		
		assertTrue(content.containsKey(23));
		assertEquals("1", content.get(23));
		
		assertTrue(content.containsKey(25));
		assertEquals("2", content.get(25));
		
		assertTrue(content.containsKey(27));
		assertEquals("3", content.get(27));
		
		assertTrue(content.containsKey(29));
		assertEquals("4", content.get(29));
		
		assertTrue(content.containsKey(20));
		assertEquals("", content.get(20));
		
		assertTrue(content.containsKey(22));
		assertEquals("java.lang.RuntimeException", content.get(22));
	}
}
